<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Dissasemble: src/process/decode/decode.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="Hopper_v3.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Dissasemble
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">This project receives as input a file.o and displays the assembly code for that object.</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('decode_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/process/decode/decode.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="decode_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> ============================================================================</span>
<a name="l00003"></a>00003 <span class="comment"> Name        : decode.h</span>
<a name="l00004"></a>00004 <span class="comment"> Author      :</span>
<a name="l00005"></a>00005 <span class="comment"> Version     :  1</span>
<a name="l00006"></a>00006 <span class="comment"> Copyright   : Your copyright notice</span>
<a name="l00007"></a>00007 <span class="comment"> Description : Perform properly disassembly process. Identifies if the byte analyzed</span>
<a name="l00008"></a>00008 <span class="comment">  corresponds to a prefix, opcode, or is a record, use the information provided by</span>
<a name="l00009"></a>00009 <span class="comment">  the XML file for this analysis</span>
<a name="l00010"></a>00010 <span class="comment"> ============================================================================</span>
<a name="l00011"></a>00011 <span class="comment"> */</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef ENCODING_H_</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define ENCODING_H_</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;<a class="code" href="config_8h.html">config.h</a>&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;<a class="code" href="debug_8h.html">debug.h</a>&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;elf.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;gelf.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;libelf.h&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;err.h&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;libelf.h&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;<a class="code" href="common_8h.html">common.h</a>&gt;</span>
<a name="l00029"></a><a class="code" href="decode_8h.html#a9b34f51c6f391e9e98cea40a041241c9">00029</a> <span class="preprocessor">#define TWO_BYTE_OPCODE (0x0F)</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a><a class="code" href="decode_8h.html#af46288fed606aabf87d393e057b80d47">00031</a> <span class="preprocessor">#define REG_TO_MEM         0</span>
<a name="l00032"></a><a class="code" href="decode_8h.html#a10c55c5d5f31915bc0b532e05a9c26b4">00032</a> <span class="preprocessor"></span><span class="preprocessor">#define MEM_TO_REG         1</span>
<a name="l00033"></a><a class="code" href="decode_8h.html#a516b510287e7d75486114e646b8f7cd5">00033</a> <span class="preprocessor"></span><span class="preprocessor">#define OPERAND_SIZE_8     0</span>
<a name="l00034"></a><a class="code" href="decode_8h.html#a98e8bd49575bfee527325412fedd5d1b">00034</a> <span class="preprocessor"></span><span class="preprocessor">#define OPERAND_SIZE_16_32 1</span>
<a name="l00035"></a><a class="code" href="decode_8h.html#ad77ca705270713c8cee0da1e3131efcf">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define MAX_OPERAND_NUMBER 4</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00038"></a><a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76">00038</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00039"></a>00039 {
<a name="l00040"></a><a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76a9639e22aeeea626bf1cfbdc8a464ee15">00040</a>         <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76a9639e22aeeea626bf1cfbdc8a464ee15">SIZE_8</a> = 8, <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76acaadd71d361a7b55bae5ab125e2485f3">SIZE_16</a>=16, <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76af8c2bd7889de0704f869521c127f1749">SIZE_32</a>=32, <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76aa211aed09197a479f3e2a24f39295eed">SIZE_64</a>=64
<a name="l00041"></a>00041 } <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76">INST_DATA_SIZE</a>;
<a name="l00042"></a>00042 
<a name="l00045"></a><a class="code" href="struct__reg__values.html">00045</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__reg__values.html" title="Structure containing the attributes of the different types of records.">_reg_values</a>
<a name="l00046"></a>00046 {
<a name="l00047"></a><a class="code" href="struct__reg__values.html#aed1cfb225a5fb77461e7972691e68a72">00047</a>         <span class="keywordtype">char</span> *<a class="code" href="struct__reg__values.html#aed1cfb225a5fb77461e7972691e68a72" title="Register name.">string</a>; 
<a name="l00048"></a><a class="code" href="struct__reg__values.html#ac049c6b79f4df8aba1cdcf7d6ffcc143">00048</a>         <span class="keywordtype">char</span> <a class="code" href="struct__reg__values.html#ac049c6b79f4df8aba1cdcf7d6ffcc143" title="Register value.">regValue</a>; 
<a name="l00049"></a><a class="code" href="struct__reg__values.html#a848a04833b6c878ad53ada74dc560c8f">00049</a>         <a class="code" href="decode_8h.html#ab08a50ead6f11683035e8b03e9a6ab76">INST_DATA_SIZE</a> <a class="code" href="struct__reg__values.html#a848a04833b6c878ad53ada74dc560c8f" title="Register size.">size</a>; 
<a name="l00050"></a>00050 } <a class="code" href="decode_8h.html#a92993569a1c5366c0406b371545e2f43">REG_VALUES</a>;
<a name="l00055"></a><a class="code" href="union__optional.html">00055</a> <span class="keyword">typedef</span> <span class="keyword">union </span><a class="code" href="union__optional.html" title="Optional Atributes.">_optional</a>
<a name="l00056"></a>00056 {
<a name="l00057"></a><a class="code" href="union__optional.html#a537893029f1863ac865b24ec727c24b8">00057</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="union__optional.html#a537893029f1863ac865b24ec727c24b8">value</a>;
<a name="l00058"></a>00058         <span class="keyword">struct</span>
<a name="l00059"></a>00059         {
<a name="l00060"></a><a class="code" href="union__optional.html#ad17bd26eeae6bf0636d3752b2b5ee8b0">00060</a>                 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="union__optional.html#ad17bd26eeae6bf0636d3752b2b5ee8b0">ss</a> :2;
<a name="l00061"></a><a class="code" href="union__optional.html#a5abc5420a7f15af7410173395b610ea8">00061</a>                 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="union__optional.html#a5abc5420a7f15af7410173395b610ea8">index</a> :3;
<a name="l00062"></a><a class="code" href="union__optional.html#aec881ae10bee95b63bf7fa52ee09f2be">00062</a>                 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="union__optional.html#aec881ae10bee95b63bf7fa52ee09f2be">base</a> :3;
<a name="l00063"></a>00063         };
<a name="l00064"></a>00064 } <a class="code" href="decode_8h.html#a536dcf8d9fd7964b03d315d81d8953ab">OPTIONAL</a>;
<a name="l00068"></a><a class="code" href="struct__displacement.html">00068</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__displacement.html" title="Displacement Atributes.">_displacement</a>
<a name="l00069"></a>00069 {
<a name="l00070"></a><a class="code" href="struct__displacement.html#a537893029f1863ac865b24ec727c24b8">00070</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="struct__displacement.html#a537893029f1863ac865b24ec727c24b8">value</a>;
<a name="l00071"></a>00071 } <a class="code" href="decode_8h.html#aa2fd339219810845994d6e4f46b97e49">DISPLACEMENT</a>;
<a name="l00075"></a><a class="code" href="struct__inmediate.html">00075</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__inmediate.html" title="Inmediate Atributes.">_inmediate</a>
<a name="l00076"></a>00076 {
<a name="l00077"></a><a class="code" href="struct__inmediate.html#a537893029f1863ac865b24ec727c24b8">00077</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="struct__inmediate.html#a537893029f1863ac865b24ec727c24b8">value</a>;
<a name="l00078"></a>00078 } <a class="code" href="decode_8h.html#a59fc127f6cf115a35ddcd265ab18f736">INMEDIATE</a>;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 
<a name="l00081"></a>00081 <span class="keywordtype">char</span> <a class="code" href="decode_8c.html#a3297beb269c3c0ed6a8e226861488785" title="State machine that controls the disassembly process.">decode</a>(<span class="keywordtype">char</span>* buf, <a class="code" href="common_8h.html#ad8ce12d83f204245685f98caf9d03944" title="One byte.">UINT8</a> *decodedSize, <a class="code" href="struct___machine_inst_format.html" title="Machine Instruction Format.">MACHINE_INSTRUCTION</a> *instructionDecoded);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 <span class="preprocessor">#endif </span><span class="comment">/* ENCODING_H_ */</span>
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="decode_8h.html">decode.h</a>      </li>

    <li class="footer">Generated on Thu Oct 11 2012 12:32:08 for Dissasemble by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
